<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 
	xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets"  
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich">
	<ui:composition template="/template/base.xhtml">
		<ui:define name="body">
			<rich:panel id="painel">
				<f:facet name="header">
					<h:outputText value="#{msg['menu']}" />
				</f:facet>
				<h:form>
					<h:panelGrid columns="2">
					
						<h:outputText value="#{msg['menu.id']}" rendered="#{menuController.bean.id != null}" class="label" />
						<h:inputText value="#{menuController.bean.id}" rendered="#{menuController.bean.id != null}" />
						
						<h:outputText value="#{msg['menu.descricao']}" />
						<h:inputText value="#{menuController.bean.descricao}" />
						
						<h:outputText value="#{msg['menu.ordem']}" />
						<h:inputText value="#{menuController.bean.ordem}">
							<f:validateLongRange minimum="0" />
						</h:inputText>
					</h:panelGrid>
					
					<h:panelGrid columns="3">
						<h:commandButton action="#{menuController.save}" value="#{msg['salvar']}" />
						<h:commandButton action="#{menuController.delete}" value="#{msg['deletar']}" rendered="#{menuController.bean.id != null}" />
						<h:commandButton action="#{menuController.backToSummary}" value="#{msg['voltar']}" />
					</h:panelGrid>
					
					<rich:panel id="linkInput">
						<f:facet name="header">
							<h:outputText value="#{msg['link']}" />
						</f:facet>
						<!-- Entrada -->
						<h:panelGrid columns="4">
							<h:outputText value="#{msg['link.id']}" />
							<h:outputText value="#{linkController.bean.id}" />
							
							<h:outputText value="#{msg['link.descricao']}" />
							<h:inputText value="#{linkController.bean.descricao}" />
							
							<h:outputText value="#{msg['link.url']}" />
							<h:inputText value="#{linkController.bean.url}" />
							
							<h:outputText value="#{msg['link.ordem']}" />
							<h:inputText value="#{linkController.bean.ordem}">
								<f:validateLongRange minimum="0" />
							</h:inputText>
							
							<h:outputText value="#{msg['link.abrirEmNovaJanela']}" />
							<h:selectOneMenu value="#{linkController.bean.abrirEmNovaJanela}" required="true">
								<f:selectItems value="#{comboController.simNao}" />
							</h:selectOneMenu>
						</h:panelGrid>
						
						<h:panelGrid columns="3" id="botoes">
							<a4j:commandButton action="#{linkController.saveOnList}" render="linkInput" value="#{msg['salvar']}">
								<f:setPropertyActionListener value="#{menuController.bean}" target="#{linkController.bean.menu}" />
							</a4j:commandButton>
							
							<a4j:commandButton action="#{linkController.removeFromList}" render="linkInput,botoes" value="#{msg['deletar']}" />
						</h:panelGrid>
						
						<!-- Fim Entrada -->
						<rich:dataTable value="#{linkController.list}" var="link" style="width: 100%;">
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{msg['link.id']}" />
								</f:facet>
								<h:outputText value="#{link.id}" />
							</rich:column>
							
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{msg['link.descricao']}" />
								</f:facet>
								<h:outputText value="#{link.descricao}" />
							</rich:column>
							
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{msg['link.url']}" />
								</f:facet>
								<h:outputText value="#{link.url}" />
							</rich:column>
							
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{msg['link.ordem']}" />
								</f:facet>
								<h:outputText value="#{link.ordem}" />
							</rich:column>
							
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{msg['link.abrirEmNovaJanela']}" />
								</f:facet>
								<h:outputText value="#{comboController.simNaoMap[link.abrirEmNovaJanela]}" />
							</rich:column>
							
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{msg['editar']}" />
								</f:facet>
								<a4j:commandLink render="linkInput" value="#{msg['editar']}" execute="@this">
									<f:setPropertyActionListener value="#{link}" target="#{linkController.bean}" />
								</a4j:commandLink>
							</rich:column>							
						</rich:dataTable>
						<!--  -->						
					</rich:panel>
					
				</h:form>
			</rich:panel>
		</ui:define>
	</ui:composition>
</html>